package com.tongda.core.message.tts;

import java.io.File;

import android.os.Handler;

/**
 * 
 * @author andy
 * 
 */
public class SendFlacThread implements Runnable {
	private Handler handler;
	private final String nameWav = GoogleHelper.sdcardPath
			+ GoogleHelper.nameWav;
	private final String nameFlac = GoogleHelper.sdcardPath
			+ GoogleHelper.nameFlac;

	public SendFlacThread(Handler handler) {
		super();
		this.handler = handler;
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			new WavToJFlac().encode(new File(nameWav), new File(nameFlac));
			String msg = GoogleHelper.post(nameFlac);
			if (handler != null)
				handler.sendMessage(handler.obtainMessage(
						GoogleHelper.SHIBIE_END, msg));
		} catch (Exception e) {
			// FIXME 同时处理异常
			e.printStackTrace();
			if (handler != null)
				handler.sendEmptyMessage(GoogleHelper.SHIBIE_ERRO);
		}

	}

}
